package org.javascud.extensions.cxf.testfailover;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.javascud.extensions.cxf.service.Hello;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class HelloFailOverClientByXML
{
    public static void main(String[] args)
    {
        ClassPathXmlApplicationContext context
                = new ClassPathXmlApplicationContext(new String[]
                {"org/javascud/extensions/cxf/testfailover/failover.xml"});
        Hello client = (Hello) context.getBean("helloClient");

        Client myclient = ClientProxy.getClient(client);
        String address = myclient.getEndpoint().getEndpointInfo().getAddress();

        System.out.println(address);

        String result1 = client.sayHello("Felix");
        System.out.println(result1);

        String result2 = client.sayHello("Felix");
        System.out.println(result2);

        String result3 = client.sayHello("Felix");
        System.out.println(result3);


        myclient = ClientProxy.getClient(client);
        address = myclient.getEndpoint().getEndpointInfo().getAddress();

        System.out.println(address);
    }
}
